package exam;


public class tesla {
    public static void main(String[] args) {
        class Solution {
            public String solution(String[] phone_numbers, String[] phone_owners, String number) {
                // write your code in Java SE 8
                for(int i=0;i<phone_numbers.length;i++){
                    if(phone_numbers[i].equals(number)){
                        return phone_owners[i];
                    }
                }
                return number;
            }
        }
        class Solution2 {
            public int solution(String[] A) {
                // write your code in Java SE 8
                int[] nums = new int[26];
                int res = 0;
                for(int i=0;i<A.length;i++){
                    String str = A[i];
                    boolean flag = false;
                    for(int j = 0;j<str.length();j++){
                        int id = str.charAt(j)-97;
                        if(nums[id]!=0){
                            flag = true;
                        }
                        nums[id] += 1;
                    }
                    if(flag){
                        for(int j=0;j<str.length();j++){
                            int id = str.charAt(j)-97;
                            nums[id] -= 1;
                        }
                    }else{
                        res += str.length();
                    }
                }
                return res;
            }
        }
    }

}
